import React, { Component } from 'react'
import styles from './EditUserInfoPage.module.css'
import { Form, Input, InputNumber, PageHeader, Radio, Button } from 'antd'
import { Redirect } from 'react-router'
import { connect } from 'react-redux'
import { setUserInfoAsync } from '../../../_redux/actions_async'
import EditUserInfoForm from '../_base/EditUserInfoForm'

class EditUserInfoPage extends Component {
  constructor (props) {
    super(props)
    this.state = {
      redirectFlag: false
    }
  }

  handleFinish = e => {
    console.log(e)
    this.props.setUserInfoAsync(e)
  }

  render () {

    if (this.state.redirectFlag) {
      return <Redirect to="/home"/>
    }

    return (
      <div className={styles.container}>
        <PageHeader
          title="编辑信息"
          subTitle="请更改你的信息"
        />
        <div className={styles.form}>
          <EditUserInfoForm handleFinish={this.handleFinish}/>
        </div>
      </div>
    )
  }
}

EditUserInfoPage.propTypes = {}

EditUserInfoPage = connect(
  Function.prototype,
  {setUserInfoAsync}
)(EditUserInfoPage)

export default EditUserInfoPage
